import React from 'react';
import RnBarcodeScanner from './components/rnBarcodeScanner';

function BarcodeScanPage({route, navigation}) {
  return (
    <RnBarcodeScanner
      onBarCodeRead={(barcode) => {
        if (route.params && route.params.parentRoute) {
          navigation.navigate(route.params.parentRoute, {
            barcode,
          });
        } else {
          navigation.goBack();
        }
      }}
      onExitScan={() => {
        navigation.goBack();
      }}
    />
  );
}

BarcodeScanPage.routeName = 'BarcodeScanPage';
BarcodeScanPage.permission = 'NonNeed';
export default BarcodeScanPage;
